import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import ViteRsw from 'vite-plugin-rsw';

const path = require('path')

function _resolve(dir: string) {
  return path.resolve(__dirname, dir);
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    ViteRsw({
      crates: [
        'wasm',
      ]
    }),
  ],
  define: {
    'process.env': {}
  },
  base: './ibms',
  build: {
    outDir: 'ibms',
    target: "esnext",
    brotliSize: false,
    chunkSizeWarningLimit: 2000,
  },
  resolve: {
    alias: {
      '@': _resolve('src'),
      '#': _resolve('types')
    }
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      }
    },
  },
  server: {
    port: 8000,
    host: '0.0.0.0',
    proxy: {
      "/login": {
        target: 'http://47.112.235.80:3000',
        // target: 'http://localhost:8080',
        ws: false,
        changeOrigin: true
      },
      "/login-server": {
        target: 'http://47.112.235.80:8088',
        // target: 'http://localhost:8080',
        ws: false,
        changeOrigin: true
      }
    }
  }
})
